package com.example.backstage.controller;

import com.example.backstage.service.ProductService;
import com.example.gok_mall.entity.Product;
import com.example.gok_mall.reponseData.ResultData;
import io.swagger.annotations.Api;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/product")
@ResponseBody
@Api(value = "产品接口类")
public class ProductController {
    @Autowired
    public ProductService productService;
    public ResultData resultData;

    //实现产品更新
    @PostMapping("/update")
    public ResultData productUpdate(Product product) {
        return productService.UpdateProduct(product);
       }

    //实现产品添加
    @PostMapping("/insert")
    public ResultData productInsert(Product product){
        return productService.insertSelective(product);
    }
    //实现产品删除
    @DeleteMapping("/delete")
    public ResultData productDelete(Integer id){
        return productService.deleteProduct(id);
    }
    //更新商品的在售状态
    @PostMapping("/set_sale_status.do")
    public ResultData setSaleStatus(HttpServletRequest httpServletRequest, Integer id, Integer status) {
        return productService.setSaleStatus(id, status);
    }
}